package com.njwb.mapper;

import com.njwb.pojo.Type;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface TypeMapper {
    @Insert("insert into t_type(t_name,t_desc) values(#{name},#{desc})")
    void add(Type type);
    @Update("update t_type set t_name = #{name},t_desc = #{desc} where t_id = #{id}")
    void update(Type type);
    @Delete("delete from t_type where t_id = #{id}")
    void delById(Integer id);

    @Select("select t_id,t_name,t_desc from t_type where t_id = #{id}")
//    @Results(id = "TypeMap",value = {
//            @Result(property = "id",column = "t_id", id = true),
//            @Result(property = "name",column = "t_name"),
//            @Result(property = "desc",column = "t_desc")
//    })
    @ResultMap("TypeMap")
    Type selectById(Integer id);

    @Select("select t_id,t_name,t_desc from t_type")
    @ResultMap("TypeMap")
    List<Type> selectList();

    @Select("select t_id,t_name,t_desc from t_type where t_name like #{name} or t_desc like #{desc} ")
    @ResultMap("TypeMap")
    List<Type> selectByCondition(@Param("name") String name,@Param("desc") String desc);



}
